import os
import filecmp
from filecmp import dircmp
import shutil

def main():
    new_dir = "E:\\BaiduNetdiskDownload\\0000"
    # old_dir = r"E:\SENTINEL2_NATIF_old"
    one_dir = "E:\\Yang\\Project\\PrivateToolBox\\data\\one"
    two_dir = "E:\\Yang\\Project\\PrivateToolBox\\data\\two"
    old_dir = "E:\\BaiduNetdiskDownload\\LUTs"
    result = dircmp(new_dir, old_dir)
    print(str(result.right_only))
    print(str(result.left_only))
    print(str(result.funny_files))
    # print(result)
    for root_new , new_dir_names, new_file_names in os.walk(new_dir):
        for new_file_name in new_file_names:

            for root_old , old_dir_names, old_file_names in os.walk(old_dir):
                for old_file_name in old_file_names:

                    if old_file_name == new_file_name:
                        new_file_path = os.path.join(root_new, new_file_name)
                        old_file_path = os.path.join(root_old, old_file_name)
                        result = filecmp.cmp(new_file_path, old_file_path)
                        if not result:
                            shutil.copyfile(new_file_path, os.path.join(one_dir, new_file_name))
                            shutil.copyfile(old_file_path, os.path.join(two_dir, old_file_name))
                            print(new_file_path, old_file_path)
    return


if __name__ == "__main__":
    main()